#ifndef TLS_FACTORY_H
#define TLS_FACTORY_H
#include <map>
#include <string>
#include <cstdio>

namespace tls{
  typedef void* (*create_method)(std::FILE*);
  struct factory{
    std::map<std::string,create_method> dict;
    void register(const std::string& name,create_method func){
      dict.insert(std::make_pair(name,func));
    }
    void* create(const std::string& name,FILE* f)const{
      return dict[name](f);
    }
  };

}//namespace tls

#endif
